#region Using directives

using System;

#endregion

namespace Hanoi.Utils.Profiles
{
    public class LastProfile : ProfileBase, IGame
    {
        static IGame _game;

        private LastProfile()
        {

        }

        #region IGame Members

        public int Start
        {
            get { return _game.Start; }
        }

        public int End
        {
            get { return _game.End; }
        }

        public int Moves
        {
            get { return _game.Moves; }
        }

        public int Size
        {
            get { return _game.Size; }
        }

        public bool TimeControled
        {
            get { return _game.TimeControled; }
        }

        public TimeSpan TimeAmount
        {
            get { return _game.TimeAmount; }
        }

        #endregion

        public static IGame Get()
        {
            if (_game == null)
            {
                System.Windows.Forms.MessageBox.Show("There is not any last known profile.\r\nRandom will be used instead", "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation, System.Windows.Forms.MessageBoxDefaultButton.Button1);
                _game = new Hanoi.Utils.Profiles.RandomProfile();
            }

            return new LastProfile();
        }

        public static void Set(IGame game)
        {
            if (!(game is LastProfile))
                _game = game;
        }
    }
}
